﻿/*
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Mvc;
using Scaffold.Views;

namespace Scaffold.AllTables
{
    public class AllTablesIndex : ScaffoldViewPage<AllTablesInfo>
    {
        public AllTablesIndex(ViewPageInfo viewInfo)
            : base(viewInfo)
        {
        }

        protected override void BuildContent(System.Text.StringBuilder sb)
        {
            sb.Append("<h2>All Tables</h2>");
            sb.Append("<table>");
            sb.Append("<tr>");

            sb.Append("<th>");
            sb.Append("Table Name");
            sb.Append("</th>");
            
            sb.Append("<th>");
            sb.Append("Action");
            sb.Append("</th>");
            
            sb.Append("</tr>");

            foreach (String s in ViewData.Tables)
            {
                sb.Append("<tr>");

                sb.Append("<td>");
                sb.Append(s);
                sb.Append("</td>");

                sb.Append("<td>");
                sb.Append(Html.ActionLink("new", "New", s));
                sb.Append("</td>");
                sb.Append("</tr>");
            }

            sb.Append("</table>");

        }
    }
}
